home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_6.lha
/
8_6
/
8_6_filebuf.h
< prev
next >
Wrap
Text File
|
1993-08-08
|
771b
|
44 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ a streambuf tied to a file via stdio
lass filebuf : public streambuf
FILE *fp; // stdio file pointer
char opened; // mode of file
ublic:
int overflow(int c = EOF);
int underflow();
// open a file and return 0 on failure
filebuf *open(const char *name, open_mode m);
int close();
filebuf()
{
opened = 0;
fp = 0;
}
// tie to already opened file
filebuf(FILE *nfp)
{
opened = 1;
fp = nfp;
}
// tie to already opened file
// using the given buffer
filebuf(FILE *nfp, char *buf, int len) :
(buf, len)
{
opened = 1;
fp = nfp;
}
~filebuf()
{ close(); }
;